package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/3/7 16:54
 * @description
 */
public class Code7 {
    public static void main(String[] args) {
        System.out.println(new Code7().reverse(1534236469));
    }

    public int reverse(int x) {
        boolean flag = false;
        if (x < 0) {
            flag = true;
            x = 0 - x;
        }

        int i = 0;
        try {
            i = Integer.parseInt(new StringBuilder(x + "").reverse().toString());
        } catch (NumberFormatException e) {
            return i;
        }
        return flag ? 0 - i : i;
    }
}
